package com.example.demo.day.config.learn.design.adapter.x2;

import java.util.HashMap;
import java.util.Map;

public class AdapterTest {
    public static void main(String[] args) {
        HttpManger manger = new HttpManger();
        Map<String, String> params = new HashMap<>();
        params.put("id","1024");

        manger.queryUserNameById(params, new OnResponseListener() {
            @Override
            public void onResponse(String response) {
                System.out.println("请求响应: " + response);
                //根据响应码不同执行不同的逻辑
                String[] res = response.split(HttpManger.DIVIDER);
                String code = res[0];
                String result = res[1];
                if (HttpManger.CODE_SUCCESS.equals(code)) {
                    System.out.println("请求成功: username = " + result);
                    return;
                }
                System.out.println("请求失败： message = " + result);
            }

            @Override
            public void onError(String code, String message) {
                System.out.println("请求出错： code = " + code + ", message = " + message);
            }
        });
    }
}
